# -*- coding: utf-8 -*-
# @Time    : 2022/5/25 9:25
# @Author  : leijiu
# @Email   : 517711635@qq.com
# @File    : user_comment_list_page.py
# @Software: PyCharm
"""
用户评论列表页面
"""

from time import sleep
from selenium.webdriver.common.by import By
from page.base_page import BasePage

class UserCommentList(BasePage):
    # def __init__(self,driver):
    #     self.driver=driver

    # 用户评论定位器
    ele_goodsadmin_locator = (By.CSS_SELECTOR, "#menu-ul > li.collapse.lis.ico_1")
    ele_usercomment_locator = (By.LINK_TEXT, "用户评论")
    # 查看详情定位器
    ele_lookusercommet_lcoator = (
    By.CSS_SELECTOR, "#listDiv > table:nth-child(1) > tbody > tr:nth-child(2) > td:nth-child(8) > a:nth-child(1)")
    # 移除用户评论
    ele_deleteresponsebtn_locator = (By.CSS_SELECTOR, "#listDiv > table:nth-child(1) > tbody > tr:nth-child(2) > td:nth-child(8) > a:nth-child(2)")
    #断言回复留言后的内容定位器
    ele_now_comment_locator = (By.XPATH,"/html/body/div[2]/table/tbody/tr[3]/td/div[1]")
    #断言删除后的编号定位器
    ele_delete_num_locator=(By.XPATH,"/html/body/form/div/table[1]/tbody/tr[2]/td[1]")
    #查看详情
    #页面切换
    def leftpage(self):
        self.driver.switch_to.frame("menu-frame")
        sleep(1)
        # 点击商品管理
    def goodsadmin(self):
        self.driver.find_element(*self.ele_goodsadmin_locator).click()
        sleep(1)
    # 点击用户评论
    def usercomment(self):
        self.driver.find_element(*self.ele_usercomment_locator).click()
    # 切换到主页面
    def mainpage(self):
        self.driver.switch_to.parent_frame()
        self.driver.switch_to.frame("main-frame")
        sleep(1)
    # 点击查看详情
    def lookusercommet(self):
        self.driver.find_element(*self.ele_lookusercommet_lcoator).click()
    # 删除用户评论
    def deleteresponsebtn(self):
        self.driver.find_element(*self.ele_deleteresponsebtn_locator).click()
        sleep(1)
        self.driver.switch_to.alert.accept()
    #断言回复评论使用
    def commentcontent(self):
        now_comment_content = self.driver.find_element(*self.ele_now_comment_locator).text
        return now_comment_content
    #断言删除评论使用
    def oldcommentnum(self):
        old_comment_numb = self.driver.find_element(*self.ele_delete_num_locator).text
        return old_comment_numb
    def nowcommentnum(self):
        now_cmment_numb = self.driver.find_element(*self.ele_delete_num_locator).text
        return now_cmment_numb